<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MD_MAX72xx LED Matrix Arduino Library: New Hardware Types</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="MajicDesigns_Logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MD_MAX72xx LED Matrix Arduino Library
   &#160;<span id="projectnumber">2.9</span>
   </div>
   <div id="projectbrief">Library to control connected  MAX72XX devices as a pixel array</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('page_new_hardware.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">New Hardware Types </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2>A word on coordinate systems </h2>
<p>Two Cartesian coordinate systems are used in the library</p><ul>
<li>one defines the pixels seen (<em>display coordinates</em>), and</li>
<li>an underlying <em>hardware coordinate</em> system based on digits and segments mapping to the MAX72xx hardware control registers.</li>
</ul>
<p>Display coordinates always have their origin in the top right corner of a display.</p><ul>
<li>Column numbers increase to the left (as do module numbers)</li>
<li>Row numbers increase down (0..7)</li>
</ul>
<p>All user functions are consistent and use display coordinates.</p>
<p>Display memory buffers are stored in hardware coordinates that depend on the hardware configuration (i.e. the module type). It is the job of the low level library functions to map display to hardware coordinates. Digit 0 is the lowest row/column number and Segment G is the lowest column/row number.</p>
<p>All the code to do this is in the is in the buffer and pixel modules. All other library modules are use the primitives made available in these modules.</p>
<h2>What needs to change? </h2>
<p>As there is no standard way of wiring a LED matrix to the MAX72xx IC, each hardware type definition activates a series of coordinate mapping transformations. Possible changes are limited to combinations (8 in total) of</p><ul>
<li>swapping rows and column coordinates (digits and segments in MAX72xx),</li>
<li>a reversal of row indices, and</li>
<li>a reversal of column indices.</li>
</ul>
<p>The hardware types defined in <a class="el" href="_m_d___m_a_x72xx_8h.html" title="Main header file for the MD_MAX72xx library. ">MD_MAX72xx.h</a> activate different library code by defining appropriate values for the defines listed below, in the <a class="el" href="_m_d___m_a_x72xx__lib_8h.html" title="Includes library definitions. ">MD_MAX72xx_lib.h</a> file.</p>
<ul>
<li>HW_DIG_ROWS - MAX72xx digits are mapped to rows in on the matrix. If digits are not rows then they are columns!</li>
<li>HW_REV_COLS - Normal column coordinates orientation is 0 col on the right side of the display. Set to 1 to reverse this (0 on the left).</li>
<li>HW_REV_ROWS - Normal row coordinates orientation is 0 row at top of the display. Set to 1 to reverse this (0 at the bottom).</li>
</ul>
<h2>Determining the type of mapping </h2>
<p>The library example code includes a utility called MD_MAX72xx_HW_Mapper. This is test software to map display hardware rows and columns. It uses a generic SPI interface and only one MAX72xx/8x8 LED module required. It is independent of the libraries as the code is used to directly map the display orientation by setting pixels on the display and printing to the serial monitor which MAX72xx hardware component (segment and digit) is being exercised.</p>
<p>By observing the LED display and the serial monitor you can build a map like the one below. It is worth noting the direction in which the rows and columns are scanned by the utility, as this is the easiest way to work out the row/column reversal values.</p>
<p>The result of these observations is a grid definition that looks somewhat like: </p><pre class="fragment">      DIG0 D1 D2 D3 D4 D5 D6 D7
Seg G
Seg F
Seg E
Seg D
Seg C
Seg B
Seg A
Seg DP
</pre><p>From this mapping it is clear</p><ul>
<li>MAX72xx digits map to the columns, HW_DIG_ROWS is 0.</li>
<li>DIG0 is on the left (columns were also scanned left to right), so HW_REV_COLS should be set to 1 to reverse it to the standard 0 on the right.</li>
<li>Seg G is at the top (rows were also top to bottom), so HW_REV_ROWS should be set to 0, as it is already standard with 0 on top.</li>
</ul>
<p>Note that in some situations using the module 'upside down' will result in a better configuration than would otherwise be the case. An example of this is the generic module mapping. Also remember that the modules are daisy chained from right to left.</p>
<p>Having determined the values for the defines, the new mapping can be configured, or matched to an existing hardware type. </p><hr/>
 </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="index.html">Arduino LED Matrix Library</a></li><li class="navelem"><a class="el" href="page_hardware.html">Hardware</a></li>
    <li class="footer">Generated on Mon Nov 14 2016 15:09:04 for MD_MAX72xx LED Matrix Arduino Library by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.12 </li>
  </ul>
</div>
</body>
</html>
